using System;
using MongoDB.Driver;
using Sustainalytics.MongoDB.Extensions;

namespace Sustainalytics.Synchronization.Validation.Internals
{
    public interface IMongoCollectionFactory<T>
    {
        IMongoCollection<T> CreateNew(string connectionString);
    }

    public class MongoCollectionFactory<T> : IMongoCollectionFactory<T>
    {
        private readonly Func<string, IMongoCollection<T>> creatorDelegate =
            connectionString => MongoFactory.GetCollectionFromDatabase<T>(connectionString);

        public IMongoCollection<T> CreateNew(string connectionString)
        {
            return creatorDelegate.Invoke(connectionString);
        }
    }


}